package com.example.demo4.webapi;


import com.example.demo4.domain.Teacher;
import com.example.demo4.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/webapi/teacher")
public class TeacherRestController {
    @Autowired
    private TeacherService teacherService;


    @GetMapping("/list")
    public List<Teacher> getAll() {
        List<Teacher> teachers=teacherService.findAll();
        return teachers;
    }
    @GetMapping("/{name}")
    public List<Teacher> findByNameLike(@PathVariable String name){

        System.out.println(name);
        List<Teacher> teachers = teacherService.findByTnameLike("%"+name+"%");
        return teachers;
    }
}
